﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SharedGenomics.Core
{
    public interface ILogger
    {
        void Log(LogEntry entry);
    }

    public enum MessagePriority
    {
        Information = 0,
        Debug,
        Warning,
        Error,
        Fatal
    }

    public static class LoggerExtensions
    {
        public static void Log<T>(this ILogger logger, string message)
        {
            logger.ThrowIfNull("logger");
            logger.Log(new LogEntry(message) { LogType = typeof(T) });
        }

        public static void Log<T>(this ILogger logger, Exception ex)
        {
            logger.ThrowIfNull("logger");
            logger.Log(new LogEntry(ex) { LogType = typeof(T) });
        }

        public static void Log<T>(this ILogger logger, Exception ex, string message)
        {
            logger.ThrowIfNull("logger");
            logger.Log(new LogEntry(ex, message) { LogType = typeof(T) });
        }

        public static void Log<T>(this ILogger logger, string message, MessagePriority priority)
        {
            logger.ThrowIfNull("logger");
            logger.Log(new LogEntry(message, priority) { LogType = typeof(T) });
        }
    }
}
